home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / c / ExtrasLib.lha / ExtrasLib / Source / EntryToNN.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-30  |  1.3 KB  |  73 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #include <clib/extras_protos.h>
  6. #include <proto/dos.h>
  7. #include <proto/exec.h>
  8.  
  9. #include <extras/entry.h>
  10.  
  11. #include <exec/types.h>
  12. #include <exec/memory.h>
  13.  
  14. #include <extras/macros.h>
  15. #include "entries.h"
  16.  
  17. /****** extras.lib/db_EntryToNN ******************************************
  18. *
  19. *   NAME
  20. *       db_EntryToNN -- Retrieve data from an ENTRY of a database.
  21. *
  22. *   SYNOPSIS
  23. *       STRPTR db_EntryToNN(BPTR File, STRPTR EntryName)
  24. *
  25. *   FUNCTION
  26. *       Get data from a Database, see db_GetEntryData().
  27. *       All the data in the entry is put into an NNString.
  28. *       The data can then be parsed with nns_GetNNData()
  29. *
  30. ******************************************************************************
  31. *
  32. */
  33.  
  34.  
  35. STRPTR db_EntryToNN(BPTR File, STRPTR EntryName)
  36. {
  37.   STRPTR str=0;
  38.   
  39.   if(!GED_Buffer)
  40.   {
  41.     GED_Buffer=malloc(BUFFERSIZE);
  42.     if(!GED_Buffer)
  43.       return(0);
  44.   }
  45.   
  46.   GED_Buffer[0]=0;
  47.  
  48.   if(db_NextEntry(File,EntryName,GED_Buffer,BUFFERSIZE))
  49.   {
  50.     if(!FGets(File,GED_Buffer,BUFFERSIZE))
  51.     {
  52.       return(0);
  53.     }
  54.     
  55.     while(GED_Buffer[0]!='}')
  56.     {
  57.       
  58.       Strip(GED_Buffer);
  59.       
  60.       if(!(str=nns_AddNNStr(str,GED_Buffer)))
  61.         return(0);
  62.         
  63.       if(!FGets(File,GED_Buffer,BUFFERSIZE))
  64.       {
  65.         FreeVec(str);
  66.         return(0);
  67.       }
  68.     }
  69.   }
  70.   return(str);
  71. }
  72.  
  73.